import React from 'react';
import styles from './index.css';
import { Button } from 'antd';
import { connect } from 'dva';

export default connect(
  // mapStateToProps
  ({ users, loading }) => ({ userList: users, loading }),
  // mapActionToProps
  {
    getUsers: () => ({ type: 'users/getUsers', payload: { title: 'AAA' } })
  }
)(function ({ userList, getUsers, loading }) {
  console.log('--->', loading);
  return (
    <div>
      <h1 className={styles.title}>Page users/index</h1>
      <hr />
      <div>{loading.models.users ? '加载中...' : ''}</div>
      <ul>
        {userList.map(user => <li key={user.id}>{user.id}号选手： {user.name} {user.age} 岁</li>)}
      </ul>
      <Button type="primary" onClick={getUsers}>获取</Button>
    </div>
  );
});
